import request from "@/utils/request";

const AUTH = "auth";
const USER_BASE = "maimao_user/sys/user";

export default {
    /**
     * 密码登录
     */
    pwdLogin(loginData, type) {
        return request({
            url: `/${AUTH}/web-login?type=${type}`,
            method: "post",
            data: loginData
        });
    },
    /**
     * 手机验证码登录
     */
    mobileLogin(loginData, type) {
        return request({
            url: `/${AUTH}/mobile-login?type=${type}`,
            method: "post",
            data: loginData
        });
    },

    /**
     * 获取登录用户的基本信息
     */
    userInfo() {
        return request({
            url: `${USER_BASE}/userinfo`,
            method: "get"
        });
    },
    logout() {
        return request({
            url: `${AUTH}/web-logout`,
            method: "post"
        });
    },

    /**
     * 获取短信验证码
     * @param {*} mobile 手机号
     */
    fetchCheckCode(mobile) {
        return request({
            url: `${AUTH}/mobile-code`,
            method: 'post',
            data: {
                mobile
            }
        })
    },
};
